<?php


namespace app\common\model;


use think\Model;

class CompanyPositionModel extends Model
{
    protected $name = 'company_position';


    /**
     * 获取公司职位详情
     * @param $company_company_id
     * @return array
     */
    public function getDetail($company_company_id): array
    {
        try {
            $data = $this->get($company_company_id,['company']);
            if($data) {
                $data->image = ImageAddDomain($data->image);
                $data->file = ImageAddDomain($data->file);
                if($data->company) {
                    $data->company->image = ImageAddDomain($data->company->image);
                    $data->company->file = ImageAddDomain($data->company->file);
                }
            }

            return [
                'code' => 200,
                'msg' => '请求成功',
                'data' => $data
            ];
        }catch (\Exception $e) {
            return [
                'code' => $e->getCode(),
                'msg' => $e->getMessage(),
                'data' => []
            ];
        }
    }


    public function company(){
        return $this->belongsTo('app\common\model\CompanyModel','company_id','id');
    }

}